package org.romzzz.gwtclassifieds.client.data;

import java.io.Serializable;
import com.extjs.gxt.ui.client.data.BaseModelData;

/**
 * Usage of the GXT data model to wrap a simple String as a category. CategoryBean instances are comparable just like String instances.
 */
public class CategoryBean extends BaseModelData implements Serializable, Comparable<CategoryBean> {
	
	private static final long serialVersionUID = 7919423548999364190L;

	public CategoryBean() {}
	
	public CategoryBean(String s) {
		setValue(s);
	}
	
	public String getValue() {
		return get("value");
	}
	
	public void setValue(String s) {
		set("value", s);
	}
	
	public boolean equals(Object o) {
		if (o instanceof CategoryBean) {
			return getValue().equals(((CategoryBean) o).getValue());
		}
		return false;
	}
	
	public String toString() {
		return getValue();
	}

	@Override
	public int compareTo(CategoryBean o) {
		return getValue().compareTo(o.getValue());
	}

}
